package es.gesfutbol.domini.implementacio;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import es.gesfutbol.domini.IForum;

@Entity
@Table (name="forum")
public class Forum implements IForum {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4897146870734806492L;

	private Long idForum;
	
	private String nom;
	
	private Penya penya;

	private Set<Comentari> comentaris;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="idForum", nullable=false, precision=10, scale=0)
	public Long getIdForum() {
		return idForum;
	}

	public void setIdForum(Long idForum) {
		this.idForum = idForum;
	}

	@Column(name="nom", nullable=false, length=45)
	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	@OneToOne
	@JoinColumn(name="idPenya", referencedColumnName = "idPenya", nullable = false)
	public Penya getPenya() {
		return penya;
	}

	public void setPenya(Penya penya) {
		this.penya = penya;
	}

	@OneToMany(fetch=FetchType.EAGER, mappedBy="forum", cascade=CascadeType.ALL)
	public Set<Comentari> getComentaris() {
		return comentaris;
	}

	public void setComentaris(Set<Comentari> comentaris) {
		this.comentaris = comentaris;
	}
}
